package leetcode.weekly.week304;

import java.util.Arrays;

//Solution2Test
public class Solution2 {

	public int maximumGroups(int[] grades) {
		long len = grades.length;
		long ans = 1;
		long l = 1, r = len;
		while (l <= r) {
			long m = ((r - l) >> 1) + l;
			long need = (1 + m) * m / 2;
			if (need > len) {
				r = m - 1;
			} else {
				ans = m;
				l = m + 1;
			}
		}
		return (int) ans;
	}

}
